home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: Binary files ?
- Date: 22 Feb 1996 07:59 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <22FEB199607593247@erich.triumf.ca>
- References: <4gheee$bvr@ci.ist.utl.pt>
- NNTP-Posting-Host: erich.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4gheee$bvr@ci.ist.utl.pt>, l40128@alfa.ist.utl.pt (delphis) writes...
- > I program in c a couple of years but i never figure out this basic
- >question : how to work with binary files ? basically, what i want to do
- >is writing a matrix to a file and read it back but when i try the
- >following code in dos the matrix comes all gobled, but works fine in unix!
- > Can anyone tell me whats wrong with this ? I have been using text files
- >and they dont give any troble at all!
-
- ># include <stdio.h>
- >void main()
-
- to avoid flames on comp.lang.c (and because the C standard say so) main()
- _must_ return an int (then you need a return 0; at the end)
- >{
- >
- > /*write file*/
- > int n;
- > unsigned char mat[200];
- > FILE *f=fopen("teste","w"); /*do i have to use the CREATE before this ?*/
-
- In DOS, if you want a binary file, you must open it with "wb" or "rb".
-
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
-
-
-
-
-
-